﻿using DicomViewerAdvanced.VirtualMouse;
using Microsoft.Kinect;
using NuiDicomPlayer.Subviews;

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Threading;
using KinectLibrary;
using NuiDicomPlayer.VirtualMouse;
using NuiDicomPlayer.Nui.Gestures;
using NuiDicomPlayer.Nui.NavigationEngine;
using NuiDicomPlayer.Nui.Speech;
using Biomedica.Graphics;


namespace NuiDicomPlayer
{
    public delegate void XthreadCall();
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
       
        public static NuiNavigator Nav { set; get; }
        public static KinectGestureManager _Manager { set; get; }
        public static mouseImposter ActiveMouse { set; get; }
        public static Vector2 SubActiveMouseVector { set; get; }
        public static SubviewBase ActiveWindow { set; get; }
        public static bool IsLeftHanded { get; set; }
        public static KinectAudioSource AudioSource { set; get; }
        public static String RootPath { set; get; }
        private void Application_Startup_1(object sender, StartupEventArgs e)
        {  
            RootPath = @"C:\Users\biomedica\SkyDrive\Repo\KinectDicomViewer\DicomViewer\NuiDicomPlayer\Dicom\";
            IsLeftHanded = true;           
           App._Manager = KinectGestureManager.New();

          
          
        }
        internal static void StartSensor()
        {
            SpeechCommander commanders = new SpeechCommander();


            App.ActiveMouse = ((MainWindow)App.Current.MainWindow).rightmousepointer;
           

            App.ActiveMouse.Enabled= true;
            
            _Manager.canvas = ((MainWindow)App.Current.MainWindow).mousecanvas;
            _Manager.OnDepthFrameReady += ((MainWindow)App.Current.MainWindow).OnDepthFrameReady;
            _Manager.IsLeftHanded = true;           
            _Manager.EnableKinect = true;
            commanders.OnSpeechRecognised += commanders_OnSpeechRecognised;
            commanders.Start(Microsoft.Kinect.KinectSensor.KinectSensors[App._Manager.ActiveSensor]);
        }

        static void commanders_OnSpeechRecognised(object sender, SpeechRecogised e)
        {
            App.ActiveWindow.DoSpeechCommand(e.recognitionResult);
        }

        private void Application_SessionEnding_1(object sender, SessionEndingCancelEventArgs e)
        { 
          

        }
        
    }
}
